﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsPageAccessDAL
/// </summary>
public class clsPageAccessDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
    public clsPageAccessDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    public int SaveRolePage(IN_TB_ROLE_PAGE objIN_TB_ROLE_PAGEOLD)
    {
        try
        {
            IN_TB_ROLE_PAGE objIN_TB_ROLE_PAGENEW = new IN_TB_ROLE_PAGE();
            objIN_TB_ROLE_PAGENEW = (from obj in objInstantNaukriDataContextDataContext.IN_TB_ROLE_PAGEs
                                     where obj.ID == objIN_TB_ROLE_PAGEOLD.ID
                                     select obj).SingleOrDefault();

            if (objIN_TB_ROLE_PAGENEW != null)
            {
                objIN_TB_ROLE_PAGENEW.ID = objIN_TB_ROLE_PAGEOLD.ID;
                objIN_TB_ROLE_PAGENEW.PAGE_ID = objIN_TB_ROLE_PAGEOLD.PAGE_ID;
                objIN_TB_ROLE_PAGENEW.CREATED_BY = objIN_TB_ROLE_PAGEOLD.CREATED_BY;
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_ROLE_PAGENEW.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_ROLE_PAGEs.InsertOnSubmit(objIN_TB_ROLE_PAGEOLD);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_ROLE_PAGEOLD.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_ROLE_PAGE GetRolePageById(int RolePageId)
    {
        try
        {
            IN_TB_ROLE_PAGE objIN_TB_ROLE_PAGENEW = new IN_TB_ROLE_PAGE();
            objIN_TB_ROLE_PAGENEW = (from obj in objInstantNaukriDataContextDataContext.IN_TB_ROLE_PAGEs
                                     where obj.ID == RolePageId
                                     select obj).SingleOrDefault();
            return objIN_TB_ROLE_PAGENEW;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public void DeleteRolePage(int RolePageId)
    {
        try
        {
            IN_TB_ROLE_PAGE objIN_TB_ROLE_PAGENEW = new IN_TB_ROLE_PAGE();
            objIN_TB_ROLE_PAGENEW = (from obj in objInstantNaukriDataContextDataContext.IN_TB_ROLE_PAGEs
                                     where obj.ID == RolePageId
                                     select obj).SingleOrDefault();
            objInstantNaukriDataContextDataContext.IN_TB_ROLE_PAGEs.DeleteOnSubmit(objIN_TB_ROLE_PAGENEW);
            objInstantNaukriDataContextDataContext.SubmitChanges();
        }
        catch (Exception)
        {

            throw;
        }
    }

}
